const path = require('path');
const webpack = require("webpack");
const { merge } = require('webpack-merge');
const common = require('./webpack.common.js');
const processEnvVariable = require('./processEnvVariable.js');

const ForkTsCheckerWebpackPlugin = require('fork-ts-checker-webpack-plugin');

module.exports = merge(common, {
  mode: 'development',
  devtool: 'inline-source-map',
  devServer: {
    static: './dist',
    client: {
      overlay: true,
      progress: false,
    },
  },
  plugins: [
    new webpack.DefinePlugin({
      'process.env': {
        ...processEnvVariable(require('dotenv').config({ path: path.resolve(__dirname, '.env.development') }).parsed)
      }
    }),
    // new ForkTsCheckerWebpackPlugin(),
  ],
  module: {
    rules: [
      // {
      //   test: /\.ts$/,
      //   exclude: /node_modules/,
      //   loader: "ts-loader",
      //   options: {
      //     appendTsSuffixTo: [/\.vue$/], // 支持 vue文件的ts代码
      //     transpileOnly: true, // 只转换ts，不进行类型检查
      //   }, 
      // },
    ]
  },
});